package com.sgz.test.bean.parameterizedType;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public abstract class SuperClass<T> {

    private Class<T> beanClass;

    @SuppressWarnings("unchecked")
    public SuperClass() {
        super();
        ParameterizedType parameterizedType =  (ParameterizedType) getClass().getGenericSuperclass();
        Type[] types = parameterizedType.getActualTypeArguments();
        System.out.println("parameterizedType.getOwnerType() = " + parameterizedType.getOwnerType());
        System.out.println("parameterizedType.getRawType() = " + parameterizedType.getRawType());
        beanClass = (Class<T>) types[0];
    }

    public Class<T> getBeanClass() {
        return beanClass;
    }

    public void setBeanClass(Class<T> beanClass) {
        this.beanClass = beanClass;
    }
    
    public static void main(String[] args) {
        SuperClass<Cat> superClass = new SubClass();
        System.out.println(superClass.getBeanClass());
    }
    
}